<?php
	
	session_start();

	$con = mysqli_connect("localhost","root","","movie");
	if(!$con)
		die("Could not connect" . mysql_error());


	$query = mysqli_query($con,"SELECT password,name FROM user WHERE email='$_POST[email]'");
	$temp = mysqli_fetch_array($query);

	
	if($temp['password'] == $_POST["password"]){
	  	echo "Welcome " . $temp['name'] . "! <br>Will direct you to the main page in 3 seconds later...";
	  	
	  	$_SESSION['check'] = true;
	  	$_SESSION['name'] = $temp['name'];
	  	$_SESSION['user'] = $_POST['email'];
	}
	else {
		echo "Error! Will go to the main page in 3 seconds later...";
		$_SESSION['check'] = false;
	}
    
    echo "<Meta http-equiv='Refresh' Content='2; Url=index.php'>";
?>